import { _decorator, Component, Node, NodePool } from 'cc';
import { Util } from './Util';
import { PoolManager } from './PoolManager';
const { ccclass, property } = _decorator;

@ccclass('Weapon')
export class Weapon extends Component {
    public attack: number = 10;
    public speed: number = 12;
    public moveDirection: number;
    public isMoving: boolean = true;

    /**阻力 */
    public resist: number = 0.1;

    protected onEnable(): void {

    }

    protected onDisable(): void {

    }

    start() {

    }

    update(deltaTime: number) {
        if (this.isMoving) {
            Util.moveNode(this.node, this.moveDirection, this.speed);

            this.speed -= this.resist;
            if (this.speed <= 0) {
                PoolManager.instance.put(this.node);
            }
        }
    }
}


